<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <h:form>

            <p:panel>
                <p:wizard flowListener="#{channelSessionWizard.onFlowProcess}">
                    <p:tab title="Select Specility" id="speciality">
                        <h:outputLabel  value="Speciality" ></h:outputLabel>
                        <p:autoComplete  forceSelection="true" value="#{channelSessionWizard.speciality}"
                                         id="acSpeciality"
                                         completeMethod="#{specialityController.completeSpeciality}"
                                         var="mysp" itemLabel="#{mysp.name}" itemValue="#{mysp}"
                                         converter="specilityCon" >
                            <!--<f:ajax event="itemSelect" execute="acSpeciality" render="scStaff"/>-->
                        </p:autoComplete>
                    </p:tab>
                    <p:tab title="Select Doctor" id="doctor" >
                        <h:outputLabel  value="Doctor" ></h:outputLabel>
                        <p:autoComplete   forceSelection="true" value="#{channelSessionWizard.currentStaff}" id="scStaff"
                                          completeMethod="#{channelSessionWizard.completeStaff}" var="mys"
                                          itemLabel="#{mys.person.nameWithTitle}" itemValue="#{mys}"
                                          converter="stfcon"   >   
                            <!--<f:ajax event="itemSelect" execute="scStaff" render="lstSelect gpDetail"  />-->
                        </p:autoComplete>
                    </p:tab>
                    <p:tab title="Select New Session Or Edit Session" id="check">
                        <p:selectOneRadio id="console" value="#{channelSessionWizard.createNewSession}" >
                            <f:selectItem itemLabel="New Session" itemValue="true" />
                            <f:selectItem itemLabel="Edit Session" itemValue="false" />
                            <!--<p:ajax process="console" update="gpSelectTextS" event="change" listener="#{channelSessionWizard.sessionListner()}"/>-->
                        </p:selectOneRadio>
                        <h:panelGrid id="gpSelectTextS">
                            <p:panel rendered="#{channelSessionWizard.createNewSession eq false}">
                                <p:selectOneListbox  id="lstSelectS" converter="sscon"   value="#{channelSessionWizard.current}" style="min-width: 100%;">
                                    <f:selectItems  value="#{channelSessionWizard.items}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                                    <!--<f:ajax render="gpDetail" execute="lstSelect" >-->
                                    <!--</f:ajax>-->
                                </p:selectOneListbox>
                            </p:panel>
                        </h:panelGrid>
                    </p:tab>
                    <p:tab title="Session">
                        <p:panel id="gpDetail">                    
                            <h:panelGrid columns="1" class="alignTop">
                                <p:panelGrid columns="2">  
                                    <p:outputLabel value="Session Name"/>
                                    <p:inputText autocomplete="off" value="#{channelSessionWizard.current.name}"/>
                                    <p:outputLabel value="Start Time"/>                        
                                    <p:calendar  value="#{channelSessionWizard.current.startingTime}" navigator="true" pattern="HH:mm" timeOnly="true">                            
                                    </p:calendar>
                                    <p:outputLabel value="Max Number"/>
                                    <p:inputText autocomplete="off" value="#{channelSessionWizard.current.maxNo}"/>
                                    <p:outputLabel value="Duration in Minutes"/>
                                    <p:inputText autocomplete="off" value="#{channelSessionWizard.current.duration}"/>
                                    <p:outputLabel value="Room Number"/>
                                    <p:inputText autocomplete="off" value="#{channelSessionWizard.current.roomNo}"/>
                                    <p:outputLabel value="Before Session" rendered="false"/>
                                    <p:autoComplete rendered="false" forceSelection="true" value="#{channelSessionWizard.current.beforeSession}" 
                                                    completeMethod="#{channelSessionWizard.completeSession}" var="mysp" itemLabel="#{mysp.name}" itemValue="#{mysp}"
                                                    converter="sscon"   >                            
                                    </p:autoComplete>
                                    <p:outputLabel value="After Session" rendered="false"/>
                                    <p:autoComplete  rendered="false" forceSelection="true" value="#{channelSessionWizard.current.afterSession}" 
                                                     completeMethod="#{channelSessionWizard.completeSession}" var="mysp" itemLabel="#{mysp.name}" itemValue="#{mysp}"
                                                     converter="sscon"   >                            
                                    </p:autoComplete>
                                    <p:outputLabel value="Displaying Count"/>
                                    <p:inputText autocomplete="off" value="#{channelSessionWizard.current.displayCount}"/>
                                    <p:outputLabel value="Displaying Percent"/>
                                    <p:inputText autocomplete="off" value="#{channelSessionWizard.current.displayPercent}"/>
                                    <p:outputLabel value="Effective From"/>
                                    <p:calendar id="efdate" value="#{channelSessionWizard.current.effectiveFrom}" pattern="dd MMMM yyyy" >                              
                                    </p:calendar>
                                    <p:outputLabel value="Effective To"/>
                                    <p:calendar id="etdate" value="#{channelSessionWizard.current.effectiveTo}" pattern="dd MMMM yyyy" >                              
                                    </p:calendar>
                                    <p:outputLabel value="Week Day" rendered="#{channelSessionWizard.createNewSession eq false}"/>
                                    <p:selectOneMenu id="wdate" value="#{channelSessionWizard.current.sessionWeekday}" disabled="true" rendered="#{channelSessionWizard.createNewSession eq false}">
                                        <f:selectItem itemLabel="Select Week Day"/>
                                        <f:selectItem itemValue="1" itemLabel="Sunday"/>
                                        <f:selectItem itemValue="2" itemLabel="Monday"/>
                                        <f:selectItem itemValue="3" itemLabel="Tuesday"/>
                                        <f:selectItem itemValue="4" itemLabel="Wednesday"/>
                                        <f:selectItem itemValue="5" itemLabel="Thursday"/>
                                        <f:selectItem itemValue="6" itemLabel="Friday"/>
                                        <f:selectItem itemValue="7" itemLabel="Sutarday"/>
                                    </p:selectOneMenu>
                                    <p:outputLabel value="Other Day" rendered="#{channelSessionWizard.createNewSession eq false}"/>
                                    <p:outputLabel value="#{channelSessionWizard.current.sessionDate}" rendered="#{channelSessionWizard.createNewSession eq false}">
                                        <f:convertDateTime pattern="dd MMMM yyyy" />
                                    </p:outputLabel>
                                    <p:outputLabel value="Session Number"></p:outputLabel>
                                    <p:autoComplete forceSelection="true" value="#{channelSessionWizard.current.sessionNumberGenerator}" 
                                                    completeMethod="#{sessionNumberGenerateConrtroller.completeSessionNumberGenerator}" 
                                                    var="mysp" itemLabel="#{mysp.name}" itemValue="#{mysp}"
                                                    converter="genConvert">                            
                                    </p:autoComplete>
                                    <p:outputLabel value="Refundable"/>
                                    <p:selectBooleanCheckbox value="#{channelSessionWizard.current.refundable}"/>
                                    <p:outputLabel value="Channel Id"/>
                                    <p:outputLabel value="#{channelSessionWizard.current.id}"/>
                                    <p:outputLabel value="Scan Fee Add"/>
                                    <p:selectBooleanCheckbox id="console2" value="#{channelSessionWizard.current.scanFee}" >
                                        <p:ajax process="console2" update="tblfee" event="change" listener="#{channelSessionWizard.scanFeeListner()}"/>
                                    </p:selectBooleanCheckbox>
<!--                                    <p:selectOneRadio id="console2" value="#{channelSessionWizard.current.scanFee}" >
                                        <f:selectItem itemLabel="Yes" itemValue="true" />
                                        <f:selectItem itemLabel="no" itemValue="false" />
                                        <p:ajax process="console2" update="tblfee" event="change" listener="#{channelSessionWizard.scanFeeListner()}"/>
                                    </p:selectOneRadio>-->
                                </p:panelGrid>
                                <br/>
                                <p:tabView rendered="#{channelSessionWizard.createNewSession ne false}" >
                                    <p:tab title="WeekDay"> 
                                        <p:selectOneMenu id="wdate" value="#{channelSessionWizard.current.sessionWeekday}">
                                            <f:selectItem itemLabel="Select Week Day"/>
                                            <f:selectItem itemValue="1" itemLabel="Sunday"/>
                                            <f:selectItem itemValue="2" itemLabel="Monday"/>
                                            <f:selectItem itemValue="3" itemLabel="Tuesday"/>
                                            <f:selectItem itemValue="4" itemLabel="Wednesday"/>
                                            <f:selectItem itemValue="5" itemLabel="Thursday"/>
                                            <f:selectItem itemValue="6" itemLabel="Friday"/>
                                            <f:selectItem itemValue="7" itemLabel="Sutarday"/>
                                        </p:selectOneMenu>
                                    </p:tab>
                                    <p:tab title="Other Day" >
                                        <p:calendar id="odate" value="#{channelSessionWizard.current.sessionDate}" pattern="dd MMMM yyyy" >                              
                                        </p:calendar>
                                    </p:tab>
                                </p:tabView>                    

                            </h:panelGrid>                   
                        </p:panel>
                    </p:tab >
                    <p:tab title="Fee For Session">
                        <p:dataTable value="#{channelSessionWizard.fees}" var="i" id="tblfee">
                            <f:facet name="header">
                                <h:outputLabel value="Channel Fees" />
                            </f:facet>
                            <p:column headerText="Fee Name">
                                <h:outputLabel value="#{i.name}"/>
                            </p:column>
                            <p:column headerText="Fee Type">
                                <h:outputLabel value="#{i.feeType}"/>
                            </p:column>
                            <p:column headerText="Specility">
                                <p:autoComplete id="acSpeciality" forceSelection="true" 
                                                value="#{i.speciality}"
                                                required="true"
                                                completeMethod="#{specialityController.completeSpeciality}"
                                                var="spe"
                                                itemLabel="#{spe.name}" 
                                                itemValue="#{spe}" 
                                                style="width: 400px;"
                                                rendered="#{i.feeType eq 'Staff'}">
                                </p:autoComplete>
                            </p:column>
                            <p:column headerText="Staff" >
                                <p:autoComplete   forceSelection="true" 
                                                  value="#{i.staff}" id="acDoc"
                                                  completeMethod="#{channelSessionWizard.completeDoctors}" 
                                                  var="mys" itemLabel="#{mys.person.nameWithTitle}" 
                                                  itemValue="#{mys}"
                                                  converter="stfcon"
                                                  rendered="#{i.feeType eq 'Staff'}">   
                                </p:autoComplete> 
                            </p:column>
                            <p:column headerText="Institution" >
                                <p:selectOneMenu id="cmbInstitution" value="#{i.institution}"
                                                 rendered="#{i.feeType eq 'OwnInstitution' or i.feeType eq 'Service'}" >
                                    <f:selectItem itemLabel="Select Institution"/>
                                    <f:selectItems value="#{institutionController.companies}" var="ins" itemLabel="#{ins.name}" itemValue="#{ins}" />
                                    <f:ajax execute="cmbInstitution" render="cmbDepartment" event="change"/>                                        
                                </p:selectOneMenu>
                            </p:column>
                            <p:column headerText="Department">
                                <h:selectOneListbox id="cmbDepartment" size="1" 
                                                    value="#{i.department}"
                                                    rendered="#{i.feeType eq 'OwnInstitution' or i.feeType eq 'Service'}" >
                                    <f:selectItem itemLabel="Select Department"/>
                                    <f:selectItems value="#{channelSessionWizard.getInstitutionDepatrments(i.institution)}" var="dep" itemLabel="#{dep.name}" itemValue="#{dep}" />
                                </h:selectOneListbox>
                            </p:column>
                            <p:column headerText="Local Fee">
                                <p:inputText value="#{i.fee}" />
                            </p:column>
                            <p:column headerText="Foreign Fee">
                                <p:inputText value="#{i.ffee}" />
                            </p:column>

                            <p:column headerText="Update">
                                <p:commandButton ajax="false" value="Update" action="#{channelSessionWizard.updateItemFee(i)}" >
                                </p:commandButton>
                            </p:column>
                        </p:dataTable>
                    </p:tab>
                </p:wizard>
            </p:panel>

        </h:form>
    </ui:define>


</ui:composition>
